<?php

if ($_SERVER['REQUEST_METHOD'] == 'POST')
{
    
$src=$_POST['src'];
//$src = 'google.jpg';
    //
    //exit($src);
    //$tem='uploads/1342017815honda_cbr600rr_green.jpg';
    require('./croping/ImageManipulation.php');
    
    $objImage = new ImageManipulation($src);
    //exit("786");
    if ( $objImage->imageok ) {
        $objImage->setCrop($_POST['x'], $_POST['y'], $_POST['w'], $_POST['h']);
        $objImage->resize(500);
        //$objImage->show();
        // uncomment the following line to save the output image.
       // $ext = pathinfo($src, PATHINFO_EXTENSION);

        
   $filename_ext = pathinfo($src, PATHINFO_EXTENSION);

$src = preg_replace('/(\.gif|\.jpg|\.png)/', '1', "$src");

        //preg_replace('/(\.gif|\.jpg|\.png)/', '1', $src);
$src=$src.".".$filename_ext;
        //exit($src);
        
        
        $objImage->save($src);
        //HttpResponse::setData($_POST['src']);
        
        
    } else {
        echo 'Error!';
    }
    exit;
}
?>
